package com.algorithm.stack;/*
 *@Author:DOWN
 *@Date:2021/12/27 18:10
 *@Comment:
 */

public class CustomStack {
    int[] stack;
    int index,maxsize;
    public CustomStack(int maxSize) {
        stack=new int[maxSize];
        index=0;
        maxsize=maxSize;
    }

    public void push(int x) {
        if(index==maxsize){
            return;
        }
        stack[index++]=x;
    }

    public int pop() {
        if(index==0){
            return -1;
        }
        return stack[--index];
    }

    public void increment(int k, int val) {
        int judge=Math.min(index,k);
        for (int i=0;i<judge;i++){
            stack[i]+=val;
        }
    }
}
